package com.newjiabo.applet.controller;

import cn.hutool.core.bean.BeanUtil;
import com.newjiabo.common.core.controller.BaseController;
import com.newjiabo.common.core.domain.AjaxResult;
import com.newjiabo.common.core.page.TableDataInfo;
import com.newjiabo.ski.domain.SkiCameraman;
import com.newjiabo.ski.domain.SkiCameramanRequestNote;
import com.newjiabo.ski.domain.vo.CameramanQuery;
import com.newjiabo.ski.domain.vo.CameramanRequestQuery;
import com.newjiabo.ski.service.ISkiCameramanRequestNoteService;
import com.newjiabo.ski.service.ISkiCameramanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 买家端,收银台接口
 *
 * @author CaoMengHui
 */
@RestController
@RequestMapping("/applet/cameraman")
@Api(tags = "小程序-摄影师接口")
public class CameramanController extends BaseController {
    @Resource
    private ISkiCameramanRequestNoteService cameramanRequestNoteService;
    @Resource
    private ISkiCameramanService cameramanService;

    @ApiOperation(value = "申请摄影师")
    @PostMapping("/note/apply")
    public AjaxResult apply(@RequestBody SkiCameramanRequestNote cameramanRequestNote){
        return toAjax(cameramanRequestNoteService.apply(cameramanRequestNote));
    }

    @ApiOperation(value = "查看申请单列表")
    @GetMapping("/note/list")
    public TableDataInfo noteList(CameramanRequestQuery query){
        startPage();
        query.setMemberId(getMemberId());
        List<SkiCameramanRequestNote> skiCameramanRequestNotes = cameramanRequestNoteService.selectSkiCameramanRequestNoteList(BeanUtil.copyProperties(query, SkiCameramanRequestNote.class));
        return getDataTable(skiCameramanRequestNotes);
    }

    @ApiOperation(value = "查看申请单详情")
    @GetMapping("/note/info/{cameramanRequestNoteId}")
    public AjaxResult noteInfo(@PathVariable @NotNull String cameramanRequestNoteId){
        return AjaxResult.success(cameramanRequestNoteService.selectSkiCameramanRequestNoteById(cameramanRequestNoteId));
    }

    @ApiOperation(value = "获取摄影师列表")
    @GetMapping(value = "/cameraman/list")
    public TableDataInfo cameramanList(CameramanQuery query){
        startPage();
        List<SkiCameraman> skiCameramenList = cameramanService.selectSkiCameramanList(BeanUtil.copyProperties(query, SkiCameraman.class));
        return getDataTable(skiCameramenList);
    }


}
